
var id;
/*编辑*/
var btns = document.getElementsByClassName("mui-bg-primary");
for(var i = 0; i < btns.length; i++) {
    btns[i].onclick = function() {
        document.getElementById('dialog').style.display = 'block';
        id = this.getAttribute('data-id');
        console.log(id);
        mui.ajax('/admin/pc/userInfo',{
            data:{
                id: id
            },
            type:'post',//HTTP请求类型
            success:function(data){
                document.getElementById('id').value=data.id;
                document.getElementById('realname').value=data.realname;
                document.getElementById('idCard').value=data.idCard;
                document.getElementById('mobile').value=data.mobile;
                document.getElementById('address').value=data.address;
                console.log(data);
            },
            error:function(data){
                console.log('data',data);
            }
        });
    }
}
/*取消*/
document.getElementById('cancel').onclick = function() {
    document.getElementById('dialog').style.display = 'none';
}
/*保存*/
document.getElementById('makesure').onclick = function() {
    var pcId = document.getElementById('id').value;
    var realname = document.getElementById('realname').value;
    var idCard = document.getElementById('idCard').value;
    var mobile = document.getElementById('mobile').value;
    var address = document.getElementById('address').value;
    mui.ajax('/admin/pc/userUpdate',{
        data:{
            id: pcId,
            realname: realname,
            idCard: idCard,
            mobile: mobile,
            address: address
        },
        type:'post',//HTTP请求类型
        success:function(data){
           location.href="/admin/pc/userList"
        },
        error:function(data){
            console.log('data',data);
        }
    });
}
/*登出*/
document.getElementById('logout').onclick = function () {
    location.href = "/admin/pc/loginOut";
}